home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / thesrc10.zip / COMM1.C < prev    next >
C/C++ Source or Header  |  1992-08-12  |  67KB  |  2,142 lines

  1. /***********************************************************************/
  2. /* COMM1.C - Commands A-E                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991,1992 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@itc.gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 7877
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42.  
  43. #include "the.h"
  44.  
  45. /*#define DEBUG 1*/
  46.  
  47. /*-------------------------- external data ----------------------------*/
  48. extern LINE *next_line,*curr_line;
  49. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  50. extern char current_screen;
  51. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  52. extern WINDOW *foot,*error_window,*divider;
  53. extern char error_on_screen;
  54. extern unsigned char *rec;
  55. extern unsigned short rec_len;
  56. extern unsigned char *cmd_rec;
  57. extern unsigned short cmd_rec_len;
  58. extern unsigned char mode_insert;        /* defines insert mode toggle */
  59. extern unsigned char in_profile;    /* indicates if processing profile */
  60.  
  61. extern unsigned char temp_cmd[150];
  62. extern unsigned char dir_filename[MAX_FILE_NAME+1];
  63. extern unsigned char dir_pathname[MAX_FILE_NAME+1];
  64. extern unsigned char sp_path[MAX_FILE_NAME+1] ;
  65. extern unsigned char sp_fname[MAX_FILE_NAME+1] ;
  66. extern unsigned char dir_path[MAX_FILE_NAME+1] ;    /* for dir and ls commands */
  67. /*---------------------- function definitions -------------------------*/
  68. #ifdef PROTO
  69. void split_command(unsigned char *,unsigned char *,unsigned char *);
  70. int param_split(unsigned char *,unsigned char *[],int );
  71. long valid_target(unsigned char *);
  72. int get_row_for_focus_line(int,long,long);
  73. void redraw_window(WINDOW *);
  74. void add_command(unsigned char *);
  75. #else
  76. void split_command();
  77. int param_split();
  78. long valid_target();
  79. int get_row_for_focus_line();
  80. void redraw_window();
  81. void add_command();
  82. #endif
  83. /*man-start*********************************************************************
  84. COMMAND
  85.      add - add blank line
  86.  
  87. SYNTAX
  88.      ADD [n]
  89.  
  90. DESCRIPTION
  91.      The ADD command inserts the specified number of blank lines after
  92.      the current_line (if issued from the command line) or after the
  93.      focus_line (if issued in the main of prefix windows).
  94.      The cursor is positioned in the column corresponding to the first
  95.      column not containing a space in the line above.
  96.  
  97. COMPATIBILITY
  98.      Compatible.
  99.  
  100. DEFAULT
  101.      With no parameters, 1 line is added.
  102.  
  103. SEE ALSO
  104.      Sos_addline
  105.  
  106. STATUS
  107.      Complete
  108. **man-end**********************************************************************/
  109. #ifdef PROTO
  110. int Add(unsigned char *params)
  111. #else
  112. int Add(params)
  113. unsigned char *params;
  114. #endif
  115. /***********************************************************************/
  116. {
  117. /*--------------------------- local data ------------------------------*/
  118. #define ADD_PARAMS  1
  119.  unsigned char *word[ADD_PARAMS+1];
  120.  char parm[ADD_PARAMS];
  121.  unsigned short num_params;
  122.  long num_lines;
  123. /*--------------------------- processing ------------------------------*/
  124. #ifdef TRACE
  125.  trace_function("comm1.c:   Add");
  126. #endif
  127. /*---------------------------------------------------------------------*/
  128. /* Validate the parameters that have been supplied. The one and only   */
  129. /* parameter should be a positive integer greater than zero.           */
  130. /* If no parameter is supplied, 1 is assumed.                          */
  131. /*---------------------------------------------------------------------*/
  132.  num_params = param_split(params,word,ADD_PARAMS);
  133.  if (num_params == 0)
  134.     {
  135.      num_params = 1;
  136.      word[0] = (unsigned char *)"1";
  137.     }
  138.  if (num_params != 1)
  139.     {
  140.      display_error(1,word[1]);
  141. #ifdef TRACE
  142.      trace_return();
  143. #endif
  144.      return(OK);
  145.     }
  146.  if (!valid_positive_integer(word[0]))
  147.     {
  148.      display_error(4,word[0]);
  149. #ifdef TRACE
  150.      trace_return();
  151. #endif
  152.      return(OK);
  153.     }
  154.  num_lines = atol(word[0]);
  155.  insert_new_line((unsigned char *)"",0,num_lines,FALSE);
  156. #ifdef TRACE
  157.  trace_return();
  158. #endif
  159.  return(OK);
  160. }
  161. /*man-start*********************************************************************
  162. COMMAND
  163.      all - select and display restricted set of lines
  164.  
  165. SYNTAX
  166.      ALL [string target]
  167.  
  168. DESCRIPTION
  169.  
  170. COMPATIBILITY
  171.      Compatible.
  172.  
  173. DEFAULT
  174.  
  175. SEE ALSO
  176.  
  177. STATUS
  178.      Not Started
  179. **man-end**********************************************************************/
  180. #ifdef PROTO
  181. int All(unsigned char *params)
  182. #else
  183. int All(params)
  184. unsigned char *params;
  185. #endif
  186. /***********************************************************************/
  187. {
  188. /*--------------------------- local data ------------------------------*/
  189. /*--------------------------- processing ------------------------------*/
  190. #ifdef TRACE
  191.  trace_function("comm1.c:   All");
  192. #endif
  193.  display_error(0,(unsigned char *)"This function has not yet been implemented");
  194. #ifdef TRACE
  195.  trace_return();
  196. #endif
  197.  return(OK);
  198. }
  199. /*man-start*********************************************************************
  200. COMMAND
  201.      autosave - set autosave period
  202.  
  203. SYNTAX
  204.      AUtosave n|OFF
  205.  
  206. DESCRIPTION
  207.      The AUTOSAVE command sets the interval between automatic saves
  208.      of the file, or turns it off altogether.
  209.  
  210. COMPATIBILITY
  211.      Compatible.
  212.  
  213. STATUS
  214.      Complete.
  215. **man-end**********************************************************************/
  216. #ifdef PROTO
  217. int Autosave(unsigned char *params)
  218. #else
  219. int Autosave(params)
  220. unsigned char *params;
  221. #endif
  222. /***********************************************************************/
  223. {
  224. /*--------------------------- extern data -----------------------------*/
  225. extern unsigned char AUSx;
  226. /*--------------------------- local data ------------------------------*/
  227. #define AUS_PARAMS  1
  228.  unsigned char *word[AUS_PARAMS+1];
  229.  register int i;
  230.  unsigned short num_params;
  231.  long num_pages,num_lines;
  232.  unsigned short x,y;
  233. /*--------------------------- processing ------------------------------*/
  234. #ifdef TRACE
  235.  trace_function("comm1.c:   Autosave");
  236. #endif
  237.  num_params = param_split(params,word,AUS_PARAMS);
  238.  if (num_params == 0)
  239.    {
  240.     display_error(3,(unsigned char *)"");
  241. #ifdef TRACE
  242.     trace_return();
  243. #endif
  244.     return(OK);
  245.    }
  246.  if (num_params != 1)
  247.    {
  248.     display_error(2,(unsigned char *)"");
  249. #ifdef TRACE
  250.     trace_return();
  251. #endif
  252.     return(OK);
  253.    }
  254.  if (strcmp(word[0],"off") == 0
  255.  ||  strcmp(word[0],"OFF") == 0)
  256.    {
  257.     CURRENT_FILE->autosave = 0;
  258. #ifdef TRACE
  259.     trace_return();
  260. #endif
  261.     return(OK);
  262.    }
  263.  if (!valid_positive_integer(word[0]))
  264.    {
  265.     display_error(4,(unsigned char *)word[0]);
  266. #ifdef TRACE
  267.     trace_return();
  268. #endif
  269.     return(OK);
  270.    }
  271.  if (in_profile)
  272.     AUSx = (unsigned char)atoi(word[0]);
  273.  else
  274.     CURRENT_FILE->autosave = (unsigned char)atoi(word[0]);
  275.  return(OK);
  276. }
  277. /*man-start*********************************************************************
  278. COMMAND
  279.      backward - scroll backwards one screen
  280.  
  281. SYNTAX
  282.      BACkward [n]
  283.  
  284. DESCRIPTION
  285.      The BACKWARD command scrolls the file contents backwards one full
  286.      screen.
  287.  
  288. COMPATIBILITY
  289.      Compatible.
  290.  
  291. DEFAULT
  292.      With no parameters, 1 screen is scrolled.
  293.  
  294. SEE ALSO
  295.      forward,top
  296.  
  297. STATUS
  298.      Complete
  299. **man-end**********************************************************************/
  300. #ifdef PROTO
  301. int Backward(unsigned char *params)
  302. #else
  303. int Backward(params)
  304. unsigned char *params;
  305. #endif
  306. /***********************************************************************/
  307. {
  308. /*--------------------------- local data ------------------------------*/
  309. #define BAC_PARAMS  1
  310.  unsigned char *word[BAC_PARAMS+1];
  311.  char parm[BAC_PARAMS];
  312.  register int i;
  313.  unsigned short num_params;
  314.  long num_pages,num_lines;
  315.  unsigned short x,y;
  316. /*--------------------------- processing ------------------------------*/
  317. #ifdef TRACE
  318.  trace_function("comm1.c:   Backward");
  319. #endif
  320.  num_params = param_split(params,word,BAC_PARAMS);
  321.  if (num_params == 0)
  322.     {
  323.      num_params = 1;
  324.      word[0] = (unsigned char *)"1";
  325.     }
  326.  if (num_params != 1)
  327.     {
  328.      display_error(1,(unsigned char *)word[1]);
  329. #ifdef TRACE
  330.     trace_return();
  331. #endif
  332.      return(OK);
  333.     }
  334.  if (strcmp(word[0],"*") == 0)
  335.    {
  336.     CURRENT_VIEW->current_line = 0L;
  337.     post_process_line(CURRENT_VIEW->focus_line);
  338.     CURRENT_VIEW->focus_line = 0L;
  339.     pre_process_line(CURRENT_VIEW->focus_line);
  340.     if (!in_profile)
  341.       {
  342.        getyx(CURRENT_WINDOW_MAIN,y,x);
  343.        show_page();
  344.        y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  345.                                CURRENT_VIEW->focus_line,
  346.                                CURRENT_VIEW->current_line);
  347.        wmove(CURRENT_WINDOW_MAIN,y,x);
  348.       }
  349. #ifdef TRACE
  350.     trace_return();
  351. #endif
  352.     return(OK);
  353.    }
  354.  if ((num_pages = atol(word[0])) == 0L)
  355.    {
  356.     display_error(4,(unsigned char *)word[0]);
  357. #ifdef TRACE
  358.     trace_return();
  359. #endif
  360.     return(OK);
  361.    }
  362.  num_lines = CURRENT_VIEW->current_line - ((CURRENT_SCREEN.rows-1)*num_pages);
  363.  CURRENT_VIEW->current_line = max(num_lines,0);
  364.  
  365.  post_process_line(CURRENT_VIEW->focus_line);
  366.  CURRENT_VIEW->focus_line = calculate_focus_line(CURRENT_VIEW->current_row,
  367.                                                 CURRENT_VIEW->focus_line,
  368.                                                 CURRENT_VIEW->current_line);
  369.  pre_process_line(CURRENT_VIEW->focus_line);
  370.  if (in_profile)
  371.    {
  372. #ifdef TRACE
  373.     trace_return();
  374. #endif
  375.     return(OK);
  376.    }
  377.  getyx(CURRENT_WINDOW_MAIN,y,x);
  378.  show_page();
  379.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  380.    {
  381.     y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  382.                                CURRENT_VIEW->focus_line,
  383.                                CURRENT_VIEW->current_line);
  384.     wmove(CURRENT_WINDOW,y,x);
  385.    }
  386. #ifdef TRACE
  387.  trace_return();
  388. #endif
  389.  return(OK);
  390. }
  391. /*man-start*********************************************************************
  392. COMMAND
  393.      bottom - move to the bottom of the file
  394.  
  395. SYNTAX
  396.      BOTtom
  397.  
  398. DESCRIPTION
  399.      The BOTTOM command moves to the very end of the current file.
  400.      The "Bottom-of-file" line is set to the current_line.
  401.  
  402.      "BOTTOM" is equivalent to "FORWARD *".
  403.  
  404. COMPATIBILITY
  405.      Compatible.
  406.  
  407. SEE ALSO
  408.      forward,top
  409.  
  410. STATUS
  411.      Complete
  412. **man-end**********************************************************************/
  413. #ifdef PROTO
  414. int Bottom(unsigned char *params)
  415. #else
  416. int Bottom(params)
  417. unsigned char *params;
  418. #endif
  419. /***********************************************************************/
  420. {
  421. /*--------------------------- local data ------------------------------*/
  422.  short rc;
  423. /*--------------------------- processing ------------------------------*/
  424. #ifdef TRACE
  425.  trace_function("comm1.c:   Bottom");
  426. #endif
  427.  rc = Forward("*");
  428. #ifdef TRACE
  429.  trace_return();
  430. #endif
  431.  return(rc);
  432. }
  433. /*man-start*********************************************************************
  434. COMMAND
  435.      cancel - quickly exit from THE
  436.  
  437. SYNTAX
  438.      CANcel
  439.  
  440. DESCRIPTION
  441.      The CANCEL command exits from THE quickly by QQUITting out of all
  442.      files currently in the ring that do not have any outstanding
  443.      alterations.
  444.  
  445. COMPATIBILITY
  446.      Compatible.
  447.  
  448. SEE ALSO
  449.      ccancel
  450.  
  451. STATUS
  452.      Complete.
  453. **man-end**********************************************************************/
  454. #ifdef PROTO
  455. int Cancel(unsigned char *params)
  456. #else
  457. int Cancel(params)
  458. unsigned char *params;
  459. #endif
  460. /***********************************************************************/
  461. {
  462. /*--------------------------- local data ------------------------------*/
  463.  VIEW_DETAILS *save_current_view=(VIEW_DETAILS *)NULL;
  464. /*--------------------------- processing ------------------------------*/
  465. #ifdef TRACE
  466.  trace_function("comm1.c:   Cancel");
  467. #endif
  468.  CURRENT_VIEW = vd_first;
  469.  while (CURRENT_VIEW != (VIEW_DETAILS *)NULL)
  470.    {
  471.     if (CURRENT_FILE->save_alt == 0)
  472.        Qquit((unsigned char *)"");
  473.     else
  474.       {
  475.        save_current_view = CURRENT_VIEW;
  476.        CURRENT_VIEW = CURRENT_VIEW->next;
  477.       }
  478.    }
  479.  if (save_current_view != (VIEW_DETAILS *)NULL)
  480.    {
  481.     CURRENT_VIEW = save_current_view;
  482.     pre_process_line(CURRENT_VIEW->focus_line);
  483.     show_page();
  484.     if (CURRENT_VIEW->prefix_on)
  485.        touchwin(CURRENT_WINDOW_PREFIX);
  486.     touchwin(CURRENT_WINDOW_COMMAND);
  487.     touchwin(CURRENT_WINDOW_MAIN);
  488.     touchwin(CURRENT_WINDOW);
  489.    }
  490. #ifdef TRACE
  491.  trace_return();
  492. #endif
  493.  return(QUIT);
  494. }
  495. /*man-start*********************************************************************
  496. COMMAND
  497.      case - set case sensitivity parameters
  498.  
  499. SYNTAX
  500.      CASE Mixed|Lower|Upper [Respect|Ignore] [Respect|Ignore]
  501.  
  502. DESCRIPTION
  503.      The CASE command sets the editor's handling of the case of text.
  504.  
  505.      The first option (which is mandatory) controls how text is entered
  506.      by the user. When LOWER or UPPER are in effect, the shift or caps
  507.      lock keys have no effect on the text being entered. When MIXED is
  508.      in effect, text is entered in the case set by the use of the shift
  509.      and caps lock keys.
  510.  
  511.      The second option determines how the editor determines if a string
  512.      target matches text in the file when the target is used in a LOCATE
  513.      command.  With IGNORE in effect, a match is
  514.      found irrespective of the case of the target or the found text.
  515.      The following strings are treated as equivalent: the THE The ThE...
  516.      With RESPECT in effect, the target and text must be the same case.
  517.      Therefore a target of 'The' only matches text containing 'The', not
  518.      'THE' or 'ThE' etc.
  519.  
  520.      The third option determines how the editor determines if a string
  521.      target matches text in the file when the target is used in a CHANGE
  522.      command.  With IGNORE in effect, a match is
  523.      found irrespective of the case of the target or the found text.
  524.      The following strings are treated as equivalent: the THE The ThE...
  525.      With RESPECT in effect, the target and text must be the same case.
  526.      Therefore a target of 'The' only matches text containing 'The', not
  527.      'THE' or 'ThE' etc.
  528.  
  529. COMPATIBILITY
  530.      Compatible.
  531.  
  532. DEFAULT
  533.      MIXED IGNORE RESPECT
  534.  
  535. STATUS
  536.      Complete
  537. **man-end**********************************************************************/
  538. #ifdef PROTO
  539. int Case(unsigned char *params)
  540. #else
  541. int Case(params)
  542. unsigned char *params;
  543. #endif
  544. /***********************************************************************/
  545. {
  546. /*--------------------------- extern data -----------------------------*/
  547. extern unsigned char CASE_Ex;
  548. extern unsigned char CASE_Lx;
  549. extern unsigned char CASE_Cx;
  550. /*--------------------------- local data ------------------------------*/
  551. #define CAS_PARAMS  3
  552.  char parm[CAS_PARAMS];
  553.  unsigned char *word[CAS_PARAMS+1];
  554.  register int i;
  555.  unsigned short num_params;
  556. /*--------------------------- processing ------------------------------*/
  557. #ifdef TRACE
  558.  trace_function("comm1.c:   Case");
  559. #endif
  560.  num_params = param_split(params,word,CAS_PARAMS);
  561.  for (i=0;i<CAS_PARAMS;i++)
  562.      parm[i] = UNDEFINED_OPERAND;
  563.  if (equal("mixed",word[0],1))
  564.     parm[0] = CASE_MIXED;
  565.  if (equal("upper",word[0],1))
  566.     parm[0] = CASE_UPPER;
  567.  if (equal("lower",word[0],1))
  568.     parm[0] = CASE_LOWER;
  569.  if (parm[0] == UNDEFINED_OPERAND)
  570.     {
  571.      display_error(1,(unsigned char *)word[0]);
  572. #ifdef TRACE
  573.      trace_return();
  574. #endif
  575.      return(OK);
  576.     }
  577.  if (strcmp(word[1],"") == 0)
  578.     parm[1] = CASE_IGNORE;
  579.  else
  580.    {
  581.     if (equal("respect",word[1],1))
  582.        parm[1] = CASE_RESPECT;
  583.     if (equal("ignore",word[1],1))
  584.        parm[1] = CASE_IGNORE;
  585.    }
  586.  if (parm[1] == UNDEFINED_OPERAND)
  587.     {
  588.      display_error(1,(unsigned char *)word[1]);
  589. #ifdef TRACE
  590.      trace_return();
  591. #endif
  592.      return(OK);
  593.     }
  594.  if (strcmp(word[2],"") == 0)
  595.     parm[2] = CASE_RESPECT;
  596.  else
  597.    {
  598.     if (equal("respect",word[2],1))
  599.        parm[2] = CASE_RESPECT;
  600.     if (equal("ignore",word[2],1))
  601.        parm[2] = CASE_IGNORE;
  602.    }
  603.  if (parm[2] == UNDEFINED_OPERAND)
  604.     {
  605.      display_error(1,(unsigned char *)word[2]);
  606. #ifdef TRACE
  607.      trace_return();
  608. #endif
  609.      return(OK);
  610.     }
  611. /*---------------------------------------------------------------------*/
  612. /* When the CASE command is found in the profile file, the default     */
  613. /* CASE settings for ALL files to be editted is set.                   */
  614. /*---------------------------------------------------------------------*/
  615.  if (in_profile)
  616.    {
  617.     CASE_Ex = parm[0];
  618.     CASE_Lx = parm[1];
  619.     CASE_Cx = parm[2];
  620.    }
  621.  else
  622.    {
  623.     CURRENT_VIEW->case_enter  = parm[0];
  624.     CURRENT_VIEW->case_locate = parm[1];
  625.     CURRENT_VIEW->case_change = parm[2];
  626.    }
  627. #ifdef TRACE
  628.  trace_return();
  629. #endif
  630.  return(OK);
  631. }
  632. /*man-start*********************************************************************
  633. COMMAND
  634.      ccancel - quickly exit from THE
  635.  
  636. SYNTAX
  637.      CCancel
  638.  
  639. DESCRIPTION
  640.      The CCANCEL command exits from THE quickly by QQUITting out of all
  641.      files currently in the ring. Any changes made to any of the files
  642.      will be lost.
  643.  
  644. COMPATIBILITY
  645.      Compatible.
  646.  
  647. SEE ALSO
  648.      cancel
  649.  
  650. STATUS
  651.      Complete.
  652. **man-end**********************************************************************/
  653. #ifdef PROTO
  654. int Ccancel(unsigned char *params)
  655. #else
  656. int Ccancel(params)
  657. unsigned char *params;
  658. #endif
  659. /***********************************************************************/
  660. {
  661. /*--------------------------- local data ------------------------------*/
  662. /*--------------------------- processing ------------------------------*/
  663. #ifdef TRACE
  664.  trace_function("comm1.c:   Ccancel");
  665. #endif
  666.  CURRENT_VIEW = vd_first;
  667.  while (CURRENT_VIEW != (VIEW_DETAILS *)NULL)
  668.    {
  669.     Qquit((unsigned char *)"");
  670.    }
  671. #ifdef TRACE
  672.  trace_return();
  673. #endif
  674.  return(QUIT);
  675. }
  676. /*man-start*********************************************************************
  677. COMMAND
  678.      change - change file text
  679.  
  680. SYNTAX
  681.      Change /string1/string2/ [target] [n] [m]
  682.  
  683. DESCRIPTION
  684.      The CHANGE command changes one string of text to another.
  685.  
  686.      The first parameter to the change command is the old and new
  687.      string values, seperated by delimiters.
  688.      The allowable delimiters are '/' '\' and '@'.
  689.  
  690.      The second parameter is the target; how many lines are to be
  691.      searched for occurrences of the first string to be changed.
  692.  
  693.      The third parameter determines how many occurrences of 'string1'
  694.      are to be changed on each line.
  695.  
  696.      The fourth parameter determines at which occurrences of 'string1'
  697.      on the line are changes to commence.
  698.  
  699. COMPATIBILITY
  700.      Compatible.
  701.  
  702. DEFAULT
  703.      1 1 1
  704.  
  705. SEE ALSO
  706.      schange
  707.  
  708. STATUS
  709.      Complete.
  710. **man-end**********************************************************************/
  711. #ifdef PROTO
  712. int Change(unsigned char *params)
  713. #else
  714. int Change(params)
  715. unsigned char *params;
  716. #endif
  717. /***********************************************************************/
  718. {
  719. /*--------------------------- local data ------------------------------*/
  720.  short rc;
  721. /*--------------------------- processing ------------------------------*/
  722. #ifdef TRACE
  723.  trace_function("comm1.c:   Change");
  724. #endif
  725.  
  726.  rc = execute_change_command(params,FALSE);
  727.  
  728. #ifdef TRACE
  729.  trace_return();
  730. #endif
  731.  return(rc);
  732. }
  733. /*man-start*********************************************************************
  734. COMMAND
  735.      cmatch - find matching bracket character
  736.  
  737. SYNTAX
  738.      ** effective only if bound to a key **
  739.  
  740. DESCRIPTION
  741.      The CMATCH command searches for the matching bracket character to
  742.      the character under the cursor.
  743.  
  744.      It handles nested sets of matching pairs.
  745.      The matching character pairs are '[]{}<>()'.
  746.  
  747. COMPATIBILITY
  748.      Compatible.
  749.  
  750. STATUS
  751.      Complete.
  752. **man-end**********************************************************************/
  753. #ifdef PROTO
  754. int Cmatch(unsigned char *params)
  755. #else
  756. int Cmatch(params)
  757. unsigned char *params;
  758. #endif
  759. /***********************************************************************/
  760. {
  761. /*--------------------------- local data ------------------------------*/
  762.  static unsigned char *match = (unsigned char *)"[]{}<>()";
  763.  unsigned short x,y;
  764.  unsigned char ch,match_ch;
  765.  register int i;
  766.  char direction_backward;
  767.  short matches=1,match_col=(-1),start_col;
  768.  long offset=0;
  769.  LINE *curr;
  770.  WINDOW *w;
  771. /*--------------------------- processing ------------------------------*/
  772. #ifdef TRACE
  773.  trace_function("comm1.c:   Cmatch");
  774. #endif
  775. /*---------------------------------------------------------------------*/
  776. /* This command only allowed to be issued from with the MAIN window.   */
  777. /*---------------------------------------------------------------------*/
  778.  if (CURRENT_VIEW->current_window != WINDOW_MAIN
  779.  || in_profile)
  780.    {
  781.     display_error(66,(unsigned char *)"");
  782. #ifdef TRACE
  783.     trace_return();
  784. #endif
  785.     return(OK);
  786.    }
  787.  if (CURRENT_VIEW->focus_line == 0
  788.  ||  CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines+1)
  789.    {
  790.     display_error(66,(unsigned char *)"");
  791. #ifdef TRACE
  792.     trace_return();
  793. #endif
  794.     return(OK);
  795.    }
  796.  getyx(CURRENT_WINDOW,y,x);
  797. /*---------------------------------------------------------------------*/
  798. /* Check if the character under the cursor is a valid match character. */
  799. /*---------------------------------------------------------------------*/
  800.  w = CURRENT_WINDOW;
  801.  ch = (unsigned char)winch(w) & A_CHARTEXT;
  802.  match_ch = 0;
  803.  for (i=0;i<strlen(match);i++)
  804.     if (ch == *(match+i))
  805.       {
  806.        direction_backward = (i % 2);
  807.        match_ch = (direction_backward) ? *(match+i-1) : *(match+i+1);
  808.        break;
  809.       }
  810.  if (match_ch == 0)
  811.    {
  812.     display_error(67,(unsigned char *)"");
  813. #ifdef TRACE
  814.     trace_return();
  815. #endif
  816.     return(OK);
  817.    }
  818. /*---------------------------------------------------------------------*/
  819. /* Calculate the actual position of the character in the LINE.         */
  820. /*---------------------------------------------------------------------*/
  821.  start_col = CURRENT_VIEW->verify_col + x - 1;
  822.  start_col += (direction_backward) ? (-1) : 1;
  823. /*---------------------------------------------------------------------*/
  824. /* Find the focus line linked list entry.                              */
  825. /*---------------------------------------------------------------------*/
  826.  post_process_line(CURRENT_VIEW->focus_line);
  827.  curr = ll_find(CURRENT_FILE->first_line,CURRENT_VIEW->focus_line);
  828.  while (curr->next != NULL && curr->prev != NULL)
  829.    {
  830.     if (direction_backward)
  831.       {
  832.        for (i=start_col;i>(-1);i--)
  833.           {
  834.            if (*(curr->line+i) == ch)
  835.              matches++;
  836.            else
  837.               if (*(curr->line+i) == match_ch)
  838.                 matches--;
  839.            if (matches == 0)       /* found matching one */
  840.              {
  841.               match_col = i;
  842.               break;
  843.              }
  844.           }
  845.        if (match_col != (-1))
  846.          break;
  847.        curr = curr->prev;
  848.        offset--;
  849.        start_col = curr->length;
  850.       }
  851.     else
  852.       {
  853.        for (i=start_col;i<curr->length;i++)
  854.           {
  855.            if (*(curr->line+i) == ch)
  856.              matches++;
  857.            else
  858.               if (*(curr->line+i) == match_ch)
  859.                 matches--;
  860.            if (matches == 0)       /* found matching one */
  861.              {
  862.               match_col = i;
  863.               break;
  864.              }
  865.           }
  866.        if (match_col != (-1))
  867.          break;
  868.        curr = curr->next;
  869.        offset++;
  870.        start_col = 0;
  871.       }
  872.    }
  873.  if (match_col == (-1))  /* no match found */
  874.    {
  875.     display_error(68,(unsigned char *)"");
  876. #ifdef TRACE
  877.     trace_return();
  878. #endif
  879.     return(OK);
  880.    }
  881. /*---------------------------------------------------------------------*/
  882. /* If we get here, we have found the matching character, so we have to */
  883. /*  move the cursor to the new column and/or line.                     */
  884. /*---------------------------------------------------------------------*/
  885.  if (offset == 0L)
  886.    {
  887.     if (match_col >= CURRENT_VIEW->verify_col-1
  888.     &&  match_col <= (CURRENT_SCREEN.cols+(CURRENT_VIEW->verify_col-1))-1)
  889. /*---------------------------------------------------------------------*/
  890. /* If the new cursor position is in the same panel and on the same line*/
  891. /* just move the cursor there and get out.                             */
  892. /*---------------------------------------------------------------------*/
  893.       {
  894.        wmove(CURRENT_WINDOW,y,match_col-(CURRENT_VIEW->verify_col-1));
  895. #ifdef TRACE
  896.        trace_return();
  897. #endif
  898.        return(OK);
  899.       }
  900.    else
  901.       {
  902.        x = CURRENT_SCREEN.cols / 2;
  903.        CURRENT_VIEW->verify_col = max(1,match_col-(short)x);
  904.        show_page();
  905.        wmove(CURRENT_WINDOW,y,(match_col-(CURRENT_VIEW->verify_col-1)));
  906. #ifdef TRACE
  907.        trace_return();
  908. #endif
  909.        return(OK);
  910.       }
  911.    }
  912.  
  913.  CURRENT_VIEW->focus_line += offset;
  914.  pre_process_line(CURRENT_VIEW->focus_line);
  915.  if (offset + y <= 0
  916.  ||  offset + y >= CURRENT_SCREEN.rows)
  917.    {
  918.     CURRENT_VIEW->current_line = CURRENT_VIEW->focus_line;
  919.     y = CURRENT_VIEW->current_row;
  920.    }
  921.  else
  922.     y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  923.                                CURRENT_VIEW->focus_line,
  924.                                CURRENT_VIEW->current_line);
  925.  if (match_col >= CURRENT_VIEW->verify_col-1
  926.  &&  match_col <= (CURRENT_SCREEN.cols+(CURRENT_VIEW->verify_col-1))-1)
  927.     x = match_col-(CURRENT_VIEW->verify_col-1);
  928.  else
  929.    {
  930.     x = CURRENT_SCREEN.cols / 2;
  931.     CURRENT_VIEW->verify_col = max(1,match_col-(short)x);
  932.     x = (match_col-(CURRENT_VIEW->verify_col-1));
  933.    }
  934.  
  935.  show_page();
  936.  wmove(CURRENT_WINDOW,y,x);
  937. #ifdef TRACE
  938.  trace_return();
  939. #endif
  940.  return(OK);
  941. }
  942. /*man-start*********************************************************************
  943. COMMAND
  944.      cmdarrows - sets the functionality of the up and down arrows on the
  945.                   command line.
  946.  
  947. SYNTAX
  948.      CMDArrows RETRIEVE|TAB
  949.  
  950. DESCRIPTION
  951.      The CMDARROWS command determines the action that occurs when the up
  952.      and down arrows are hit while the cursor is on the command line.
  953.      CMDARROWS RETRIEVE (the default) will set the up and down arrows
  954.      to retrieve the last or next command entered on the command line.
  955.      CMDARROWS TAB will set the up and down arrows to move to the last
  956.      or first line respectively of the main window.
  957.  
  958. COMPATIBILITY
  959.      New function.
  960.  
  961. STATUS
  962.      Complete.
  963. **man-end**********************************************************************/
  964. #ifdef PROTO
  965. int Cmdarrows(unsigned char *params)
  966. #else
  967. int Cmdarrows(params)
  968. unsigned char *params;
  969. #endif
  970. /***********************************************************************/
  971. {
  972. /*------------------------- external data -----------------------------*/
  973. extern unsigned char CMDARROWSTABx;
  974. /*--------------------------- local data ------------------------------*/
  975. /*--------------------------- processing ------------------------------*/
  976. #ifdef TRACE
  977.  trace_function("comm1.c:   Cmdarrows");
  978. #endif
  979.  if (strcmp(params,"tab") == 0)
  980.    {
  981.     CMDARROWSTABx = TRUE;
  982. #ifdef TRACE
  983.     trace_return();
  984. #endif
  985.     return(OK);
  986.    }
  987.  if (strcmp(params,"retrieve") == 0)
  988.    {
  989.     CMDARROWSTABx = FALSE;
  990. #ifdef TRACE
  991.     trace_return();
  992. #endif
  993.     return(OK);
  994.    }
  995.  
  996.  display_error(1,(unsigned char *)params);
  997. #ifdef TRACE
  998.  trace_return();
  999. #endif
  1000.  return(OK);
  1001. }
  1002. /*man-start*********************************************************************
  1003. COMMAND
  1004.      colour - set colours for display
  1005.  
  1006. SYNTAX
  1007.      [SET] colour | color area [modifier] [foreground background]
  1008.  
  1009. DESCRIPTION
  1010.      The COLOUR command changes the colours or display attributes of
  1011.      various display areas in THE.
  1012.  
  1013.      Valid values for 'area':
  1014.        filearea - area containing file lines
  1015.        curline  - the current line
  1016.        block    - marked block
  1017.        cblock   - current line if in marked block
  1018.        cmdline  - command line
  1019.        idline   - line containing file specific info
  1020.        msgline  - error messages
  1021.        arrow    - command line prompt
  1022.        prefix   - prefix area
  1023.        pending  - pending commands in prefix
  1024.        scale    - line showing scale line (N/A)
  1025.        tofeof   - *** Top of File *** and *** Bottom of File *** lines
  1026.        ctofeof  - as above if the same as current line
  1027.        tabline  - line showing tab positions (N/A)
  1028.        shadow   - hidden line marker lines (N/A)
  1029.        statarea - line showing status of editting session
  1030.        divider  - dividing line between vertical split screens
  1031.  
  1032.      Valid values for 'foreground' and 'background':
  1033.        black,blue,green,cyan,red,magenta,yellow,white
  1034.  
  1035.      Valid values for 'modifier':
  1036.        normal,blink,bold,reverse,underline
  1037.  
  1038. COMPATIBILITY
  1039.      Does not implement all modifiers.
  1040.  
  1041. STATUS
  1042.      Complete.
  1043. **man-end**********************************************************************/
  1044. #ifdef PROTO
  1045. int Colour(unsigned char *params)
  1046. #else
  1047. int Colour(params)
  1048. unsigned char *params;
  1049. #endif
  1050.  
  1051. /***********************************************************************/
  1052. {
  1053. /*--------------------------- local data ------------------------------*/
  1054.  struct areas
  1055.  {
  1056.   unsigned char *area;
  1057.   short area_min_len;
  1058.   short area_window;
  1059.  };
  1060.  typedef struct areas AREAS;
  1061.  static AREAS valid_areas[ATTR_MAX]=
  1062.  {
  1063.   {(unsigned char *)"filearea",1,WINDOW_MAIN},
  1064.   {(unsigned char *)"curline",2,WINDOW_MAIN},
  1065.   {(unsigned char *)"block",1,WINDOW_MAIN},
  1066.   {(unsigned char *)"cblock",2,WINDOW_MAIN},
  1067.   {(unsigned char *)"cmdline",1,WINDOW_COMMAND},
  1068.   {(unsigned char *)"idline",1,WINDOW_IDLINE},
  1069.   {(unsigned char *)"msgline",1,WINDOW_ERROR},
  1070.   {(unsigned char *)"arrow",1,WINDOW_ARROW},
  1071.   {(unsigned char *)"prefix",2,WINDOW_PREFIX},
  1072.   {(unsigned char *)"pending",1,WINDOW_PREFIX},
  1073.   {(unsigned char *)"scale",1,WINDOW_MAIN},
  1074.   {(unsigned char *)"tofeof",2,WINDOW_MAIN},
  1075.   {(unsigned char *)"ctofeof",2,WINDOW_MAIN},
  1076.   {(unsigned char *)"tabline",1,WINDOW_MAIN},
  1077.   {(unsigned char *)"shadow",2,WINDOW_MAIN},
  1078.   {(unsigned char *)"statarea",2,WINDOW_FOOTING},
  1079.   {(unsigned char *)"divider",1,WINDOW_DIVIDER}
  1080.  };
  1081. #define COL_PARAMS 2
  1082.  unsigned char *word[COL_PARAMS+1];
  1083.  char parm[COL_PARAMS];
  1084.  register int i;
  1085.  unsigned short num_params;
  1086.  int area;
  1087.  chtype fg,bg,mod;
  1088. /*--------------------------- processing ------------------------------*/
  1089. #ifdef TRACE
  1090.  trace_function("comm1.c:   Colour");
  1091. #endif
  1092.  num_params = param_split(params,word,COL_PARAMS);
  1093.  if (num_params < 2 )
  1094.     {
  1095.      display_error(3,(unsigned char *)"");
  1096. #ifdef TRACE
  1097.      trace_return();
  1098. #endif
  1099.      return(OK);
  1100.     }
  1101. /*---------------------------------------------------------------------*/
  1102. /* Check that the supplied area matches one of the values in the area  */
  1103. /* array and that the length is at least as long as the minimum.       */
  1104. /*---------------------------------------------------------------------*/
  1105.  parm[0] = FALSE;
  1106.  for (i=0;i<ATTR_MAX;i++)
  1107.     {
  1108.      if (equal(valid_areas[i].area,word[0],valid_areas[i].area_min_len))
  1109.        {
  1110.         parm[0] = TRUE;
  1111.         area = i;
  1112.         break;
  1113.        }
  1114.     }
  1115.  if (parm[0] == FALSE)
  1116.     {
  1117.      display_error(1,(unsigned char *)word[0]);
  1118. #ifdef TRACE
  1119.      trace_return();
  1120. #endif
  1121.      return(OK);
  1122.     }
  1123. /*---------------------------------------------------------------------*/
  1124. /* Determine colours and modifiers.                                    */
  1125. /*---------------------------------------------------------------------*/
  1126.  
  1127.  if (parse_colours(word[1],&fg,&bg,&mod) == ERROR)
  1128.    {
  1129. #ifdef TRACE
  1130.     trace_return();
  1131. #endif
  1132.     return(ERROR);
  1133.    }
  1134. /*---------------------------------------------------------------------*/
  1135. /* If we are still in the profile, save the colour setup for later...  */
  1136. /*---------------------------------------------------------------------*/
  1137.  
  1138.  if (in_profile)
  1139.    {
  1140.     colour[area] = (chtype)1;
  1141.     save_fg[area] = fg;
  1142.     save_bg[area] = bg;
  1143.     save_mod[area] = mod;
  1144. #ifdef TRACE
  1145.     trace_return();
  1146. #endif
  1147.     return(OK);
  1148.    }
  1149. /*---------------------------------------------------------------------*/
  1150. /* Set the colours.                                                    */
  1151. /*---------------------------------------------------------------------*/
  1152.  
  1153.  set_colour(area,fg,bg,mod);
  1154.  
  1155. /*---------------------------------------------------------------------*/
  1156. /* Update the appropriate window with the new colour combination.      */
  1157. /*---------------------------------------------------------------------*/
  1158.  
  1159.  switch (valid_areas[area].area_window)
  1160.    {
  1161.     case WINDOW_MAIN:
  1162.                         if (area == ATTR_FILEAREA)
  1163.                            wattrset(CURRENT_WINDOW_MAIN,colour[area]);
  1164.                         redraw_window(CURRENT_WINDOW_MAIN);
  1165.                         show_page();
  1166.                         touchwin(CURRENT_WINDOW_MAIN);
  1167.                         wnoutrefresh(CURRENT_WINDOW_MAIN);
  1168.                         break;
  1169.     case WINDOW_PREFIX:
  1170.                         if (CURRENT_VIEW->prefix_on)
  1171.                           {
  1172.                            wattrset(CURRENT_WINDOW_PREFIX,colour[area]);
  1173.                            redraw_window(CURRENT_WINDOW_PREFIX);
  1174.                            touchwin(CURRENT_WINDOW_PREFIX);
  1175.                            wnoutrefresh(CURRENT_WINDOW_PREFIX);
  1176.                           }
  1177.                         break;
  1178.     case WINDOW_COMMAND:
  1179.                         wattrset(CURRENT_WINDOW_COMMAND,colour[area]);
  1180.                         redraw_window(CURRENT_WINDOW_COMMAND);
  1181.                         touchwin(CURRENT_WINDOW_COMMAND);
  1182.                         wnoutrefresh(CURRENT_WINDOW_COMMAND);
  1183.                         break;
  1184.     case WINDOW_ARROW:
  1185.                         wattrset(CURRENT_WINDOW_ARROW,colour[area]);
  1186.                         redraw_window(CURRENT_WINDOW_ARROW);
  1187.                         touchwin(CURRENT_WINDOW_ARROW);
  1188.                         wnoutrefresh(CURRENT_WINDOW_ARROW);
  1189.                         break;
  1190.     case WINDOW_IDLINE:
  1191.                         wattrset(CURRENT_WINDOW_IDLINE,colour[area]);
  1192.                         redraw_window(CURRENT_WINDOW_IDLINE);
  1193.                         touchwin(CURRENT_WINDOW_IDLINE);
  1194.                         wnoutrefresh(CURRENT_WINDOW_IDLINE);
  1195.                         break;
  1196.     case WINDOW_FOOTING:
  1197.                         wattrset(foot,colour[area]);
  1198.                         redraw_window(foot);
  1199.                         touchwin(foot);
  1200.                         wnoutrefresh(foot);
  1201.                         break;
  1202.     case WINDOW_ERROR:
  1203.                         wattrset(error_window,colour[area]);
  1204.                         break;
  1205.     case WINDOW_DIVIDER:
  1206.                         wattrset(divider,colour[area]);
  1207.                         break;
  1208.     default:
  1209.                         break;
  1210.    }
  1211. #ifdef TRACE
  1212.  trace_return();
  1213. #endif
  1214.  return(OK);
  1215. }
  1216.  
  1217. /*man-start*********************************************************************
  1218. COMMAND
  1219.      control_char - allow control characters to be entered
  1220.  
  1221. SYNTAX
  1222.      ** effective only if bound to a key **
  1223.  
  1224. DESCRIPTION
  1225.      The CONTROL_CHAR command prompts the user to enter a control character.
  1226.  
  1227. COMPATIBILITY
  1228.      New feature.
  1229.  
  1230. STATUS
  1231.      Complete.
  1232. **man-end**********************************************************************/
  1233. #ifdef PROTO
  1234. int Control_char(unsigned char *params)
  1235. #else
  1236. int Control_char(params)
  1237. unsigned char *params;
  1238. #endif
  1239. /***********************************************************************/
  1240. {
  1241. /*--------------------------- local data ------------------------------*/
  1242.  unsigned short key;
  1243. /*--------------------------- processing ------------------------------*/
  1244. #ifdef TRACE
  1245.  trace_function("comm1.c:   Control_char");
  1246. #endif
  1247.  display_error(0,(unsigned char *)"Press the character you require.");
  1248.  touchwin(error_window);
  1249.  doupdate();
  1250.  key = my_getch(CURRENT_WINDOW);
  1251.  if (islower(key))
  1252.     key = toupper(key);
  1253.  if (key >= '@'
  1254.  &&  key <= '_')
  1255.    {
  1256.     error_on_screen = NO;
  1257.     touchwin(foot);
  1258. #ifdef TRACE
  1259.     trace_return();
  1260. #endif
  1261.     return((RAW_KEY*2)+key-'@');
  1262.    }
  1263.  display_error(69,(unsigned char *)"- must be between '@' and '_'");
  1264. #ifdef TRACE
  1265.  trace_return();
  1266. #endif
  1267.  return(ERROR);
  1268. }
  1269. /*man-start*********************************************************************
  1270. COMMAND
  1271.      copy - copies text from one position to another
  1272.  
  1273. SYNTAX
  1274.      COPY BLOCK
  1275.  
  1276. DESCRIPTION
  1277.      The COPY command copies text from one part of a file to another.
  1278.      The text can be in the same file or a different file.
  1279.  
  1280. COMPATIBILITY
  1281.      Does not implement target option.
  1282.  
  1283. STATUS
  1284.      Complete.
  1285. **man-end**********************************************************************/
  1286. #ifdef PROTO
  1287. int Copy(unsigned char *params)
  1288. #else
  1289. int Copy(params)
  1290. unsigned char *params;
  1291. #endif
  1292. /***********************************************************************/
  1293. {
  1294. /*--------------------------- local data ------------------------------*/
  1295. #define COPY_PARAMS  1
  1296.  unsigned char *word[COPY_PARAMS+1];
  1297.  unsigned short num_params;
  1298.  long num_lines;
  1299.  LINE *curr,*old_curr;
  1300.  register int i;
  1301.  unsigned short y,x;
  1302.  unsigned long li;
  1303. /*--------------------------- processing ------------------------------*/
  1304. #ifdef TRACE
  1305.  trace_function("comm1.c:   Copy");
  1306. #endif
  1307.  num_params = param_split(params,word,COPY_PARAMS);
  1308.  if (strcmp(word[0],"block") != 0)
  1309.    {
  1310.     display_error(1,(unsigned char *)word[0]);
  1311. #ifdef TRACE
  1312.     trace_return();
  1313. #endif
  1314.     return(OK);
  1315.    }
  1316. /*---------------------------------------------------------------------*/
  1317. /* If on the command line, error.                                      */
  1318. /*---------------------------------------------------------------------*/
  1319.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1320.    {
  1321.     display_error(38,(unsigned char *)"");
  1322. #ifdef TRACE
  1323.     trace_return();
  1324. #endif
  1325.     return(OK);
  1326.    }
  1327. /*---------------------------------------------------------------------*/
  1328. /* If no marked block in any view, return error.                       */
  1329. /*---------------------------------------------------------------------*/
  1330.  if (MARK_VIEW == (VIEW_DETAILS *)NULL)
  1331.    {
  1332.     display_error(44,(unsigned char *)"");
  1333. #ifdef TRACE
  1334.     trace_return();
  1335. #endif
  1336.     return(OK);
  1337.    }
  1338.  post_process_line(CURRENT_VIEW->focus_line);
  1339. /*---------------------------------------------------------------------*/
  1340. /* Determine the number of lines in the marked block (any view)        */
  1341. /*---------------------------------------------------------------------*/
  1342.  num_lines = MARK_VIEW->mark_end_line-MARK_VIEW->mark_start_line+1L;
  1343. /*---------------------------------------------------------------------*/
  1344. /* Find the LINE pointer for start of marked block.                    */
  1345. /*---------------------------------------------------------------------*/
  1346.  old_curr = ll_find(MARK_FILE->first_line,MARK_VIEW->mark_start_line);
  1347. /*---------------------------------------------------------------------*/
  1348. /* Find the LINE pointer for the current focus line.                   */
  1349. /* If the focus line is the bottom of file line, subtract 1 from it.   */
  1350. /*---------------------------------------------------------------------*/
  1351.  if (CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines+1)
  1352.     li = 1L;
  1353.  else
  1354.     li = 0L;
  1355.  curr = ll_find(CURRENT_FILE->first_line,CURRENT_VIEW->focus_line-li);
  1356. /*---------------------------------------------------------------------*/
  1357. /* Add each line from the marked view after the current focus line.    */
  1358. /*---------------------------------------------------------------------*/
  1359.  for (i=0;i<num_lines;i++)
  1360.     {
  1361.      if ((curr = add_line(CURRENT_FILE->first_line,curr,
  1362.                           old_curr->line,old_curr->length)) == NULL)
  1363.        {
  1364.         display_error(30,(unsigned char *)"");
  1365. #ifdef TRACE
  1366.         trace_return();
  1367. #endif
  1368.         return(ERROR);
  1369.        }
  1370.      old_curr = old_curr->next;
  1371.     }
  1372. /*---------------------------------------------------------------------*/
  1373. /* Increment the number of lines counter for the current file and the  */
  1374. /* number of alterations.                                              */
  1375. /*---------------------------------------------------------------------*/
  1376.  increment_alt();
  1377.  CURRENT_FILE->number_lines += num_lines;
  1378. /*---------------------------------------------------------------------*/
  1379. /* Set the highlighting of lines up. The newly copied block remains    */
  1380. /* marked in the current view and the previous marked block is reset.  */
  1381. /*---------------------------------------------------------------------*/
  1382.  MARK_VIEW->mark_start_line = MARK_VIEW->mark_end_line = (-1L);
  1383.  CURRENT_VIEW->mark_start_line = CURRENT_VIEW->focus_line + 1L;
  1384.  CURRENT_VIEW->mark_end_line = CURRENT_VIEW->focus_line + num_lines;
  1385.  
  1386.  CURRENT_VIEW->focus_line = CURRENT_VIEW->mark_start_line;
  1387.  
  1388.  MARK_VIEW = CURRENT_VIEW;
  1389.  
  1390. /*---------------------------------------------------------------------*/
  1391. /* The following does a 'reset block' in the current view.             */
  1392. /*---------------------------------------------------------------------*/
  1393.  CURRENT_VIEW->mark_start_line = CURRENT_VIEW->mark_end_line = (-1L);
  1394.  MARK_VIEW = (VIEW_DETAILS *)NULL;
  1395.  
  1396.  pre_process_line(CURRENT_VIEW->focus_line);
  1397.  
  1398.  getyx(CURRENT_WINDOW,y,x);
  1399.  if (y == CURRENT_SCREEN.rows-1)      /* on bottom line of window */
  1400.    {
  1401.     CURRENT_VIEW->current_line = CURRENT_VIEW->focus_line;
  1402.     y = CURRENT_VIEW->current_row;
  1403.     i = 0;
  1404.    }
  1405.  else
  1406.    i = 1;
  1407.  show_page();
  1408.  wmove(CURRENT_WINDOW,y+i,x);
  1409.  
  1410. #ifdef TRACE
  1411.  trace_return();
  1412. #endif
  1413.  return(OK);
  1414. }
  1415. /*man-start*********************************************************************
  1416. COMMAND
  1417.      define - assign a command to a key
  1418.  
  1419. SYNTAX
  1420.      DEFine key-name command [parameters]
  1421.  
  1422. DESCRIPTION
  1423.      The DEFINE command allows the user assign a command and an optional
  1424.      parameter to a key.
  1425.  
  1426.      key-names correspond to the key values specified in the 'curses.h'
  1427.      file.
  1428.  
  1429. COMPATIBILITY
  1430.      Minimal. No support for in-memory macro commands.
  1431.  
  1432. STATUS
  1433.      Complete.
  1434. **man-end**********************************************************************/
  1435. #ifdef PROTO
  1436. int Define(unsigned char *params)
  1437. #else
  1438. int Define(params)
  1439. unsigned char *params;
  1440. #endif
  1441. /***********************************************************************/
  1442. {
  1443. /*--------------------------- local data ------------------------------*/
  1444. #define DEF_PARAMS  3
  1445.  unsigned char *word[DEF_PARAMS+1];
  1446.  char parm[DEF_PARAMS];
  1447.  register int i;
  1448.  unsigned short num_params;
  1449.  long num_lines,true_line;
  1450.  unsigned short x,y;
  1451.  LINE *curr;
  1452. /*--------------------------- processing ------------------------------*/
  1453. #ifdef TRACE
  1454.  trace_function("comm1.c:   Define");
  1455. #endif
  1456.  num_params = param_split(params,word,DEF_PARAMS);
  1457.  if (num_params < 2)
  1458.    {
  1459.     display_error(3,(unsigned char *)"");
  1460. #ifdef TRACE
  1461.     trace_return();
  1462. #endif
  1463.     return(OK);
  1464.    }
  1465.  if (num_params > 3)
  1466.    {
  1467.     display_error(2,(unsigned char *)"");
  1468. #ifdef TRACE
  1469.     trace_return();
  1470. #endif
  1471.     return(OK);
  1472.    }
  1473.  add_define(word[0],word[1],word[2]);
  1474. #ifdef TRACE
  1475.  trace_return();
  1476. #endif
  1477.  return(OK);
  1478. }
  1479. /*man-start*********************************************************************
  1480. COMMAND
  1481.      delete - delete lines from a file
  1482.  
  1483. SYNTAX
  1484.      DELete [target]
  1485.  
  1486. DESCRIPTION
  1487.      The DELETE command allows the user remove lines from the current
  1488.      file. The number of lines removed depends on the target specified.
  1489.      Lines are removed starting with the current_line.
  1490.  
  1491. COMPATIBILITY
  1492.      Compatible.
  1493.  
  1494. DEFAULT
  1495.      1 (the current line)
  1496.  
  1497. SEE ALSO
  1498.      Sos_delete
  1499.  
  1500. STATUS
  1501.      Complete.
  1502. **man-end**********************************************************************/
  1503. #ifdef PROTO
  1504. int Delete_line(unsigned char *params)
  1505. #else
  1506. int Delete_line(params)
  1507. unsigned char *params;
  1508. #endif
  1509. /***********************************************************************/
  1510. {
  1511. /*--------------------------- local data ------------------------------*/
  1512. #define DEL_PARAMS  1
  1513.  unsigned char *word[DEL_PARAMS+1];
  1514.  char parm[DEL_PARAMS];
  1515.  register int i;
  1516.  unsigned short num_params;
  1517.  long num_lines,true_line;
  1518.  unsigned short x,y;
  1519.  char direction;
  1520.  LINE *curr;
  1521. /*--------------------------- processing ------------------------------*/
  1522. #ifdef TRACE
  1523.  trace_function("comm1.c:   Delete_line");
  1524. #endif
  1525. /*---------------------------------------------------------------------*/
  1526. /* Validate the parameters that have been supplied. The one and only   */
  1527. /* parameter should be a positive integer greater than zero.           */
  1528. /* If no parameter is supplied, 1 is assumed.                          */
  1529. /*---------------------------------------------------------------------*/
  1530.  num_params = param_split(params,word,DEL_PARAMS);
  1531.  if (num_params == 0)
  1532.     {
  1533.      num_params = 1;
  1534.      word[0] = (unsigned char *)"1";
  1535.     }
  1536.  if (num_params != 1)
  1537.    {
  1538.     display_error(1,(unsigned char *)word[1]);
  1539. #ifdef TRACE
  1540.     trace_return();
  1541. #endif
  1542.     return(OK);
  1543.    }
  1544. /*---------------------------------------------------------------------*/
  1545. /* Get the correct number of lines to delete. If too many are specified*/
  1546. /* the following call will reduce the number of lines to 1 less than   */
  1547. /* the last line.                                                      */
  1548. /*---------------------------------------------------------------------*/
  1549.  if (strcmp(word[0],"block") == 0)
  1550.    {
  1551.     if (CURRENT_VIEW->mark_end_line == (-1L)
  1552.     &&  CURRENT_VIEW->mark_start_line == (-1L))
  1553.       {
  1554.        display_error(44,(unsigned char *)"");
  1555. #ifdef TRACE
  1556.        trace_return();
  1557. #endif
  1558.        return(OK);
  1559.       }
  1560.     num_lines = CURRENT_VIEW->mark_end_line-CURRENT_VIEW->mark_start_line+1L;
  1561.    }
  1562.  else
  1563.     if ((num_lines = valid_target(word[0])) == TARGET_ERROR)
  1564.       {
  1565.        display_error(4,(unsigned char *)word[0]);
  1566. #ifdef TRACE
  1567.        trace_return();
  1568. #endif
  1569.        return(OK);
  1570.       }
  1571.  if (num_lines == TARGET_NOT_FOUND)
  1572.    {
  1573.     display_error(17,(unsigned char *)"");
  1574. #ifdef TRACE
  1575.     trace_return();
  1576. #endif
  1577.     return(OK);
  1578.    }
  1579. /*---------------------------------------------------------------------*/
  1580. /* Determine in which direction we are deleting.                       */
  1581. /*---------------------------------------------------------------------*/
  1582.  if (num_lines < 0)
  1583.    {
  1584.     direction = DIRECTION_BACKWARD;
  1585.     num_lines = num_lines * (-1L);
  1586.    }
  1587.  else
  1588.    direction = DIRECTION_FORWARD;
  1589. /*---------------------------------------------------------------------*/
  1590. /* Check from which window the command was issued and make adjustments */
  1591. /* as required.                                                        */
  1592. /* Commands issued from the command window relate to the current line, */
  1593. /* commands issued from either the prefix or main window relate to the */
  1594. /* focus line.                                                         */
  1595. /*---------------------------------------------------------------------*/
  1596.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1597.  || in_profile)
  1598.    {
  1599.     true_line = CURRENT_VIEW->current_line;
  1600.     if (true_line == 0L)
  1601.       {
  1602.        true_line++;
  1603.        num_lines--;
  1604.       }
  1605.     if (true_line == CURRENT_FILE->number_lines+1)
  1606.       {
  1607.        true_line--;
  1608.        num_lines--;
  1609.       }
  1610.    }
  1611.  else
  1612.    {
  1613.     true_line = CURRENT_VIEW->focus_line;
  1614.     if (true_line == CURRENT_FILE->number_lines+1L || true_line == 0L)
  1615.       {
  1616.        display_error(38,(unsigned char *)"");
  1617. #ifdef TRACE
  1618.        trace_return();
  1619. #endif
  1620.        return(OK);
  1621.       }
  1622.    }
  1623.  
  1624.  post_process_line(true_line);
  1625.  
  1626.  if (strcmp(word[0],"block") == 0)
  1627.     if (in_profile)
  1628.       {
  1629.        display_error(25,(unsigned char *)word[0]);
  1630. #ifdef TRACE
  1631.        trace_return();
  1632. #endif
  1633.        return(ERROR);
  1634.       }
  1635.     else
  1636.        true_line = CURRENT_VIEW->mark_start_line;
  1637. /*---------------------------------------------------------------------*/
  1638. /* Find the current LINE pointer for the true_line.                    */
  1639. /* This is the line to be deleted.                                     */
  1640. /*---------------------------------------------------------------------*/
  1641.  curr = ll_find(CURRENT_FILE->first_line,true_line);
  1642. /*---------------------------------------------------------------------*/
  1643. /* Delete from the linked list the number of lines specified in the    */
  1644. /* direction specified.                                                */
  1645. /*---------------------------------------------------------------------*/
  1646. /* for (i=0;i<num_lines,curr->next != NULL;i++) */
  1647.  for (i=0;i<num_lines;i++)
  1648.     {
  1649.      add_to_recovery_list(curr->line,curr->length);
  1650.      curr = ll_del(CURRENT_FILE->first_line,curr,direction);
  1651.     }
  1652. /*---------------------------------------------------------------------*/
  1653. /* Special problem for sos_delline. As the current_line is left where  */
  1654. /* it is, when deleting a line using sos_delline and the current_line  */
  1655. /* is on the bottom-of-file the current_line MUST be reduced by the    */
  1656. /* number of lines deleted. This test can be done here as it is not    */
  1657. /* possible to have this situation when the Delete command is issued   */
  1658. /* from the command window.                                            */
  1659. /*---------------------------------------------------------------------*/
  1660.  if (CURRENT_VIEW->current_line == CURRENT_FILE->number_lines+1)
  1661.     CURRENT_VIEW->current_line -= num_lines;
  1662. /*---------------------------------------------------------------------*/
  1663. /* Decrement the number of lines counter for the current file and the  */
  1664. /* number of alterations.                                              */
  1665. /*---------------------------------------------------------------------*/
  1666.  increment_alt();
  1667.  CURRENT_FILE->number_lines -= num_lines;
  1668.  
  1669.  if (direction == DIRECTION_BACKWARD)
  1670.    {
  1671.     CURRENT_VIEW->current_line -= num_lines;
  1672.     CURRENT_VIEW->focus_line -= num_lines;
  1673.    }
  1674. /*---------------------------------------------------------------------*/
  1675. /* If we are in the profile, then don't do any more processing.        */
  1676. /*---------------------------------------------------------------------*/
  1677.  if (in_profile)
  1678.    {
  1679.     pre_process_line(CURRENT_VIEW->focus_line);
  1680. #ifdef TRACE
  1681.     trace_return();
  1682. #endif
  1683.     return(OK);
  1684.    }
  1685.  if (strcmp(word[0],"block") == 0)
  1686.    {
  1687.     CURRENT_VIEW->mark_start_line = CURRENT_VIEW->mark_end_line = (-1L);
  1688.     MARK_VIEW = (VIEW_DETAILS *)NULL;
  1689.    }
  1690.  else
  1691. /*---------------------------------------------------------------------*/
  1692. /* Fix the positioning of the marked block (if there is one and it is  */
  1693. /* in the current view and we are not deleting a block).               */
  1694. /*---------------------------------------------------------------------*/
  1695.   {
  1696.    if (direction == DIRECTION_FORWARD)
  1697.       adjust_marked_block(NO,true_line,num_lines);
  1698.    else
  1699.       adjust_marked_block(NO,true_line-num_lines+1,num_lines);
  1700.   }
  1701.  if (strcmp(word[0],"block") == 0)
  1702.    {
  1703.     if (CURRENT_VIEW->current_line > CURRENT_FILE->number_lines)
  1704.        CURRENT_VIEW->current_line = CURRENT_FILE->number_lines;
  1705.     if (CURRENT_VIEW->focus_line > CURRENT_FILE->number_lines)
  1706.        CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  1707.    }
  1708.  pre_process_line(CURRENT_VIEW->focus_line);
  1709.  show_page();
  1710.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1711.    {
  1712.     getyx(CURRENT_WINDOW,y,x);
  1713.     y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  1714.                                CURRENT_VIEW->focus_line,
  1715.                                CURRENT_VIEW->current_line);
  1716.     wmove(CURRENT_WINDOW,y,x);
  1717.    }
  1718. #ifdef TRACE
  1719.  trace_return();
  1720. #endif
  1721.  return(OK);
  1722. }
  1723. /*man-start*********************************************************************
  1724. COMMAND
  1725.      directory - list the specified directory
  1726.  
  1727. SYNTAX
  1728.      DIRectory [directory]
  1729.  
  1730. DESCRIPTION
  1731.      The DIRECTORY command displays all files in the specified directory.
  1732.      When no parameter is supplied, the current directory is displayed.
  1733.  
  1734. COMPATIBILITY
  1735.      Compatible.
  1736.  
  1737. STATUS
  1738.      Complete.
  1739. **man-end**********************************************************************/
  1740. #ifdef PROTO
  1741. int Directory(unsigned char *params)
  1742. #else
  1743. int Directory(params)
  1744. unsigned char *params;
  1745. #endif
  1746. /***********************************************************************/
  1747. {
  1748. /*--------------------------- local data ------------------------------*/
  1749. #define DIR_PARAMS  1
  1750.  unsigned char *word[DIR_PARAMS+1];
  1751.  unsigned short num_params;
  1752. /*--------------------------- processing ------------------------------*/
  1753. #ifdef TRACE
  1754.  trace_function("comm1.c:   Directory");
  1755. #endif
  1756. /*---------------------------------------------------------------------*/
  1757. /* Validate the parameters that have been supplied. The one and only   */
  1758. /* parameter should be the directory to display.                       */
  1759. /*---------------------------------------------------------------------*/
  1760.  num_params = param_split(params,word,DIR_PARAMS);
  1761.  if (num_params > 1)
  1762.    {
  1763.     display_error(1,(unsigned char *)word[1]);
  1764. #ifdef TRACE
  1765.     trace_return();
  1766. #endif
  1767.     return(OK);
  1768.    }
  1769. /*---------------------------------------------------------------------*/
  1770. /* Validate that the supplied directory is valid.                      */
  1771. /*---------------------------------------------------------------------*/
  1772.  if (splitpath(word[0]) == ERROR)
  1773.    {
  1774.     display_error(10,(unsigned char *)word[0]);
  1775. #ifdef TRACE
  1776.     trace_return();
  1777. #endif
  1778.     return(ERROR);
  1779.    }
  1780.  if (read_directory() == ERROR)
  1781.    {
  1782.     display_error(10,(unsigned char *)word[0]);
  1783. #ifdef TRACE
  1784.     trace_return();
  1785. #endif
  1786.     return(ERROR);
  1787.    }
  1788.  strcpy(temp_cmd,dir_pathname);
  1789.  strcat(temp_cmd,dir_filename);
  1790.  Edit(temp_cmd);
  1791. #ifdef TRACE
  1792.  trace_return();
  1793. #endif
  1794.  return(OK);
  1795. }
  1796. /*man-start*********************************************************************
  1797. COMMAND
  1798.      down_arrow - move the cursor down one line
  1799.  
  1800. SYNTAX
  1801.      ** effective only if bound to a key **
  1802.  
  1803. DESCRIPTION
  1804.      The down_arrow command moves the cursor down one line in the main
  1805.      window. Scrolling of the window occurs if the cursor is on the last
  1806.      line of the window.
  1807.  
  1808.      When on the command line, this command moves forward through the
  1809.      list of previous command line commands or tabs to the first line of
  1810.      the main window depending on the value set by the function
  1811.      cmdarrows. (default is the former)
  1812.  
  1813. COMPATIBILITY
  1814.      Compatible.
  1815.  
  1816. SEE ALSO
  1817.      Up_arrow
  1818.  
  1819. STATUS
  1820.      Complete.
  1821. **man-end**********************************************************************/
  1822. #ifdef PROTO
  1823. int Down_arrow(unsigned char *params)
  1824. #else
  1825. int Down_arrow(params)
  1826. unsigned char *params;
  1827. #endif
  1828. /***********************************************************************/
  1829. {
  1830. /*------------------------- external data -----------------------------*/
  1831. extern unsigned char CMDARROWSTABx;
  1832. /*--------------------------- local data ------------------------------*/
  1833.  unsigned short x,y;
  1834. /*--------------------------- processing ------------------------------*/
  1835. #ifdef TRACE
  1836.  trace_function("comm1.c:   Down_arrow");
  1837. #endif
  1838.  switch(CURRENT_VIEW->current_window)
  1839.   {
  1840.    case WINDOW_PREFIX:
  1841.    case WINDOW_MAIN:
  1842.         getyx(CURRENT_WINDOW,y,x);
  1843. /*---------------------------------------------------------------------*/
  1844. /* If the cursor is on the last line of the file...                    */
  1845. /*---------------------------------------------------------------------*/
  1846.         if (CURRENT_VIEW->current_line+y-
  1847.            CURRENT_VIEW->current_row == CURRENT_FILE->number_lines+1)
  1848.            {
  1849. /*---------------------------------------------------------------------*/
  1850. /* ... and the last line of the file is on the current row, stay there.*/
  1851. /*---------------------------------------------------------------------*/
  1852.             if (CURRENT_VIEW->current_line ==
  1853.                 CURRENT_FILE->number_lines+1)
  1854.                 break;
  1855. /*---------------------------------------------------------------------*/
  1856. /* ... and the last line of the file is below the current row,         */
  1857. /* scroll the window up one line.                                      */
  1858. /*---------------------------------------------------------------------*/
  1859.             CURRENT_VIEW->current_line++;
  1860.             show_page();
  1861.             wmove(CURRENT_WINDOW,y-1,x);
  1862.             break;
  1863.            }
  1864. /*---------------------------------------------------------------------*/
  1865. /* If on the bottom of the window, scroll the window up 1 line.        */
  1866. /*---------------------------------------------------------------------*/
  1867.         if (y == CURRENT_SCREEN.rows-1) /* on bottom of window */
  1868.            {
  1869.             CURRENT_VIEW->current_line++;
  1870.             post_process_line(CURRENT_VIEW->focus_line);
  1871.             CURRENT_VIEW->focus_line++;
  1872.             pre_process_line(CURRENT_VIEW->focus_line);
  1873.             show_page();
  1874.             wmove(CURRENT_WINDOW,y,x);
  1875.             break;
  1876.            }
  1877. /*---------------------------------------------------------------------*/
  1878. /* We are in the middle of the window, so just move the cursor down    */
  1879. /* 1 line.                                                             */
  1880. /*---------------------------------------------------------------------*/
  1881.         wmove(CURRENT_WINDOW,y+1,x);
  1882.         post_process_line(CURRENT_VIEW->focus_line);
  1883.         CURRENT_VIEW->focus_line++;
  1884.         pre_process_line(CURRENT_VIEW->focus_line);
  1885.         break;
  1886.    case WINDOW_COMMAND:
  1887. /*---------------------------------------------------------------------*/
  1888. /* Cycle forward  through the command list or tab to first line.       */
  1889. /*---------------------------------------------------------------------*/
  1890.         if (CMDARROWSTABx)
  1891.           {
  1892.            getyx(CURRENT_WINDOW,y,x);
  1893.            if (CURRENT_VIEW->prefix_on != TRUE
  1894.            ||  CURRENT_VIEW->prefix_left != TRUE)
  1895.               x += 6;
  1896.            if (CURRENT_VIEW->current_line > CURRENT_VIEW->current_row)
  1897.              {
  1898.               CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line -
  1899.                                         CURRENT_VIEW->current_row ;
  1900.               y = 0;
  1901.              }
  1902.            else
  1903.              {
  1904.               CURRENT_VIEW->focus_line = 0;
  1905.               y = CURRENT_VIEW->current_row -
  1906.                                         CURRENT_VIEW->current_line ;
  1907.              }
  1908.            pre_process_line(CURRENT_VIEW->focus_line);
  1909.            CURRENT_VIEW->current_window = WINDOW_MAIN;
  1910.            wmove(CURRENT_WINDOW,y,x);
  1911.           }
  1912.         else
  1913.            Retrieve("+");
  1914.         break;
  1915.    default:
  1916.         display_error(2,(unsigned char *)"");
  1917.         break;
  1918.   }
  1919. #ifdef TRACE
  1920.  trace_return();
  1921. #endif
  1922.  return(OK);
  1923. }
  1924. /*man-start*********************************************************************
  1925. COMMAND
  1926.      edit - edit another file
  1927.  
  1928. SYNTAX
  1929.      Edit [filename]
  1930.  
  1931. DESCRIPTION
  1932.      The EDIT command allows the user to edit another file. The new file
  1933.      is placed in the file ring. The previous file being editted remains
  1934.      in memory and can be returned to by issuing an EDIT command without
  1935.      any parameters. Several files can be editted at once, and all files
  1936.      are arranged in a ring, with subsequent EDIT commands moving through
  1937.      the ring, one file at a time.
  1938.  
  1939. COMPATIBILITY
  1940.      Compatible.
  1941.  
  1942. STATUS
  1943.      Complete.
  1944. **man-end**********************************************************************/
  1945. #ifdef PROTO
  1946. int Edit(unsigned char *params)
  1947. #else
  1948. int Edit(params)
  1949. unsigned char *params;
  1950. #endif
  1951. /***********************************************************************/
  1952. {
  1953. /*--------------------------- local data ------------------------------*/
  1954.  char old_current_file;
  1955.  unsigned short y,x;
  1956. #ifndef VMS
  1957.  SCREEN_DETAILS *screen0=&screen[0];
  1958.  SCREEN_DETAILS *screen1=&screen[1];
  1959. #endif
  1960. /*--------------------------- processing ------------------------------*/
  1961. #ifdef TRACE
  1962.  trace_function("comm1.c:   Edit");
  1963. #endif
  1964.  if (strcmp(params,"") == 0)
  1965.    {
  1966.     if (CURRENT_VIEW->next == (VIEW_DETAILS *)NULL
  1967.     &&  CURRENT_VIEW->prev == (VIEW_DETAILS *)NULL)
  1968.        return(OK);
  1969.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  1970.     wclrtoeol(CURRENT_WINDOW_COMMAND);
  1971.     memset(cmd_rec,' ',COLS);
  1972.     cmd_rec_len = 0;
  1973.     post_process_line(CURRENT_VIEW->focus_line);
  1974.     if (CURRENT_VIEW->next == (VIEW_DETAILS *)NULL)
  1975.        CURRENT_VIEW = vd_first;
  1976.     else
  1977.        CURRENT_VIEW = CURRENT_VIEW->next;
  1978.     pre_process_line(CURRENT_VIEW->focus_line);
  1979.     show_page();
  1980.     if (CURRENT_VIEW->prefix_on)
  1981.        touchwin(CURRENT_WINDOW_PREFIX);
  1982.     touchwin(CURRENT_WINDOW_COMMAND);
  1983.     touchwin(CURRENT_WINDOW_MAIN);
  1984.     CURRENT_SCREEN.screen_view = CURRENT_VIEW;
  1985. #ifdef TRACE
  1986.     trace_return();
  1987. #endif
  1988.     return(OK);
  1989.    }
  1990.  wmove(CURRENT_WINDOW_COMMAND,0,0);
  1991.  wclrtoeol(CURRENT_WINDOW_COMMAND);
  1992.  memset(cmd_rec,' ',COLS);
  1993.  cmd_rec_len = 0;
  1994.  post_process_line(CURRENT_VIEW->focus_line);
  1995.  if (get_file(params) == ERROR)
  1996.    {
  1997. #ifdef TRACE
  1998.     trace_return();
  1999. #endif
  2000.     return(ERROR);
  2001.    }
  2002.  set_up_windows();
  2003.  pre_process_line(CURRENT_VIEW->focus_line);
  2004.  show_page();
  2005. /* touchwin(CURRENT_WINDOW_PREFIX);*/
  2006. /* touchwin(CURRENT_WINDOW_COMMAND);*/
  2007. /* touchwin(CURRENT_WINDOW_MAIN);*/
  2008. /* touchwin(CURRENT_WINDOW);*/
  2009. #ifdef TRACE
  2010.  trace_return();
  2011. #endif
  2012.  return(OK);
  2013. }
  2014. /*man-start*********************************************************************
  2015. COMMAND
  2016.      enter - execute a command
  2017.  
  2018. SYNTAX
  2019.      ** effective only if bound to a key **
  2020.  
  2021. DESCRIPTION
  2022.      The ENTER command executes the command currently displayed on the
  2023.      command line, if the cursor is currently displayed there.
  2024.      If the key associated with ENTER is pressed while in the main or
  2025.      prefix window, then the cursor will move to the first column of the
  2026.      next line. If the mode is currently in 'insert', then a new line
  2027.      is added and the cursor placed at the first column of the new line.
  2028.  
  2029. COMPATIBILITY
  2030.      Compatible.
  2031.  
  2032. STATUS
  2033.      Complete.
  2034. **man-end**********************************************************************/
  2035. #ifdef PROTO
  2036. int Enter(unsigned char *params)
  2037. #else
  2038. int Enter(params)
  2039. unsigned char *params;
  2040. #endif
  2041. /***********************************************************************/
  2042. {
  2043. /*--------------------------- local data ------------------------------*/
  2044.  unsigned short x,y;
  2045.  short rc;
  2046.  register int i;
  2047.  static char first=TRUE;
  2048.  static char number_of_commands=0;
  2049.  WINDOW *w;
  2050. /*--------------------------- processing ------------------------------*/
  2051. #ifdef TRACE
  2052.  trace_function("comm1.c:   Enter");
  2053. #endif
  2054.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  2055.    {
  2056.     for (i=0;i<cmd_rec_len;i++)
  2057.         temp_cmd[i] = cmd_rec[i];
  2058.     temp_cmd[cmd_rec_len] = '\0';
  2059.     strtrunc(temp_cmd);
  2060.     add_command(temp_cmd);
  2061.     rc = command_line(temp_cmd);
  2062. #ifdef TRACE
  2063.     trace_return();
  2064. #endif
  2065.     return(rc);
  2066.    }
  2067. /* check for insert mode or not */
  2068.  if (mode_insert)
  2069.     Sos_addline("");
  2070.  else
  2071.    {
  2072.     Down_arrow((unsigned char *)"");
  2073.     getyx(CURRENT_WINDOW,y,x);
  2074.     wmove(CURRENT_WINDOW,y,0);
  2075.    }
  2076. #ifdef TRACE
  2077.  trace_return();
  2078. #endif
  2079.  return(OK);
  2080. }
  2081. /*man-start*********************************************************************
  2082. COMMAND
  2083.      eolout - set end of line terminator
  2084.  
  2085. SYNTAX
  2086.      EOLout CRLF|LF
  2087.  
  2088. DESCRIPTION
  2089.      The EOLOUT command allows the user to specify the combination of
  2090.      characters that terminate a line. Lines of text in U*ix files are
  2091.      usually terminated with a LF, whereas in DOS they usually end with
  2092.      a CR and LF combination.
  2093.  
  2094. COMPATIBILITY
  2095.      Does not implement CR option.
  2096.  
  2097. STATUS
  2098.      Complete.
  2099. **man-end**********************************************************************/
  2100. #ifdef PROTO
  2101. int Eolout(unsigned char *params)
  2102. #else
  2103. int Eolout(params)
  2104. unsigned char *params;
  2105. #endif
  2106. /***********************************************************************/
  2107. {
  2108. /*--------------------------- extern data -----------------------------*/
  2109. extern unsigned char EOLx;
  2110. /*--------------------------- local data ------------------------------*/
  2111. #define EOLOUT_PARAMS  1
  2112.  unsigned char *word[EOLOUT_PARAMS+1];
  2113.  unsigned short num_params;
  2114.  unsigned char eolchar;
  2115. /*--------------------------- processing ------------------------------*/
  2116. #ifdef TRACE
  2117.  trace_function("comm1.c:   Eolout");
  2118. #endif
  2119.  num_params = param_split(params,word,EOLOUT_PARAMS);
  2120.  if (strcmp(word[0],"lf") == 0)
  2121.     eolchar = EOLOUT_LF;
  2122.  else
  2123.     if (strcmp(word[0],"crlf") == 0)
  2124.        eolchar = EOLOUT_CRLF;
  2125.     else
  2126.       {
  2127.        display_error(1,(unsigned char *)word[0]);
  2128. #ifdef TRACE
  2129.        trace_return();
  2130. #endif
  2131.        return(ERROR);
  2132.       }
  2133.  if (in_profile)
  2134.     EOLx = eolchar;
  2135.  else
  2136.     CURRENT_FILE->eolout = eolchar;
  2137. #ifdef TRACE
  2138.  trace_return();
  2139. #endif
  2140.  return(OK);
  2141. }
  2142.